package de.h_da.fbi.cg.pointcloud.adt;

import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.util.BufferUtils;

/**
 * @author Nicolas Gramlich
 * @since 14:56:29 - 15.11.2010
 */
public class GraphEdgeMesh extends Mesh {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	// ===========================================================
	// Constructors
	// ===========================================================

	public GraphEdgeMesh(final Graph pGraph) {
		this.setMode(Mode.Lines);

		final EdgeList edges = pGraph.mEdges;

		final int edgeCount = edges.size();
		final float[] edgeCoordinates = new float[edgeCount * 3 * 2];

		for(int i = 0, j = 0; i < edgeCount; i++) {
			final Edge edge = edges.get(i);

			final Vertex vertexA = edge.mVertexA;
			edgeCoordinates[j++] = vertexA.mX;
			edgeCoordinates[j++] = vertexA.mY;
			edgeCoordinates[j++] = vertexA.mZ;

			final Vertex vertexB = edge.mVertexB;
			edgeCoordinates[j++] = vertexB.mX;
			edgeCoordinates[j++] = vertexB.mY;
			edgeCoordinates[j++] = vertexB.mZ;
		}

		this.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(edgeCoordinates));
	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================

	// ===========================================================
	// Inner and Anonymous Classes
	// ===========================================================
}
